//
//  ProOrderCenterViewController.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/27.
//  Copyright © 2020 王洋. All rights reserved.
//
#import "XLPageViewController.h"
#import "ProOrderSubListViewController.h"

#import "ProOrderCenterViewController.h"

@interface ProOrderCenterViewController ()
<XLPageViewControllerDelegate,
XLPageViewControllerDataSrouce>

@property (nonatomic, strong) XLPageViewController *pageViewController;

@end

@implementation ProOrderCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self initPageViewController];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [[BA_JobManager manager] checkTriggerWithType:BA_JobManagerType_JLAct comption:^(BOOL success) {
            if (success) {
                JobModel *model = [[BA_JobManager manager] getJobWithType:BA_JobManagerType_JLAct];
                [[TT_JumpManager sharedManager] jumpWithModel:model.actionModel completion:^(BOOL success, NSString * _Nonnull message) {
                    [[BA_JobManager manager] removeJobWithType:BA_JobManagerType_JLAct];
                    NSLog(@"[[BA_JobManager manager] removeJobWithType:BA_JobManagerType_JLAct]");
                }];
            }
        }];
    });

}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)initPageViewController {
    self.pageViewController = [[XLPageViewController alloc] initWithConfig:self.config];
    self.pageViewController.view.frame = self.view.bounds;
    self.pageViewController.delegate = self;
    self.pageViewController.dataSource = self;
    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];
}

#pragma mark -
#pragma mark TableViewDelegate&DataSource
- (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index {
    ProOrderSubListViewController *vc = [[ProOrderSubListViewController alloc] initWithType:index];
    return vc;
}

- (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index {
    return self.titles[index];
}

- (NSInteger)pageViewControllerNumberOfPage {
    return self.titles.count;
}

- (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index {
    NSLog(@"切换到了：%@",self.titles[index]);
}

@end
